﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class article_tag : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BoundList();
        }
    }

    protected void BoundList()
    {
        DataSet ds = new DataSet();
        int num;
        ds = new Cstudy.BLL.postTag().SelectPostTag(AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out num, "@count");
        AspNetPager1.RecordCount = num;
        tagList.DataSource = ds.Tables[0].DefaultView;
        tagList.DataBind();
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BoundList();
    }
    protected void tagList_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Repeater rep = e.Item.FindControl("articlelist") as Repeater;//找到里层的repeater对象
            DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
            int tagID = Convert.ToInt32(rowv["TagID"]); //获取填充子类的id 
            DataSet ds = new DataSet();
            ds = new Cstudy.BLL.Artcles().SelectArtcleByTagIDWithCount(tagID, 6);
            rep.DataSource = ds.Tables[0].DefaultView;
            rep.DataBind();
        }
    }
}